package financeapi;

public class AuthorizeController
{
	private PaymentProcessor processor;
	private int id;
	private AuthorizerCollection collection;

	public AuthorizeController()
	{
		processor = new PaymentProcessor();
		id=0;
		collection = new AuthorizerCollection();
	}

	public int AuthorizeSale(AuthorizeCallback cb,float total,String type)
	{
		AuthorizeObject obj = new AuthorizeObject();
		if(type == "Credit")
		{
			processor.readCard();
			CreditPayment pay = (CreditPayment)processor.getType();
			obj.setAccountId(pay.getCardNumber());
		}
		else
			processor.readCash();

		AuthorizeThread thread = new AuthorizeThread(id++,cb,processor.getType(),
													 total,collection,obj);
		thread.start();
		return id;
	}
}
